<!DOCTYPE html>
<html lang="fr">
	<head>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="description" content="Description de la page en quelques phrases/" />
		<meta name="author" content="Frakass" />
		<title>Titre de la page</title>
		<link rel="stylesheet" href="style.css" />
	</head>
<body>
	<div id="bloc-page">
		<header>
			<div id="titre-principale">		
				<h1> Titre de la page </h1>
			</div>
					<nav>
 						<ul>
 							<li><a href="#">accueil</a></li>
 							<li><a href="#">bts sio</a></li>
 							<li><a href="#">cycle bachelor</a></li>
 							<li><a href="#">cycle ingénieur</a></li>
 							
 						</ul>
		
					</nav>
		</header>
<body>
<section>
<?php
session_start();
include_once("DataBase.php");
include_once("constante.php");

		/*déclaration des variable:
		$lastname = array("");
		$firstname = array("");
		$pseudo = array("");
		$regEmailAddress = array("");
		$regPassword = array("");
		$promotion =array("");
		$year = array("");
		$ecole = array("");*/

		//Les champs sont bien rempli :
	 	if((isset($_POST['lastname'])) and(isset($_POST['firstname'])) and(isset($_POST['PSEUDO'])) and(isset($_POST['regEmailAddress']))  and(isset($_POST['regPassword'])) and(isset($_POST['promotion'])) and(isset($_POST['year'])) and(isset($_POST['ecole'])))
		{
		//Récupération des variables:
		$lastname = $_POST['lastname'];
		$firstname = $_POST['firstname'];
		$pseudo = $_POST['PSEUDO'];
		$regEmailAddress = $_POST['regEmailAddress'];
		$regPassword = $_POST['regPassword'];
		$promotion = $_POST['promotion'];
		$year = $_POST['year'];
		$ecole = $_POST['ecole'];
	
	$db = connect();
		
		//Préparation et éxecution de la requète d'insertion :
		$req = $db->prepare('INSERT INTO users(PROFILEID ,LASTNAME, FIRSTNAME, PSEUDO, MAIL, PASSWORD, PROMOTION, YEAR, ECOLE) VALUES( :profileid , :lastname , :firstname , :pseudo , :regEmailAddress , :regPassword , :promotion , :year , :ecole)');
		$req->execute(array(
		'profileid' => 2,
		'lastname' => $_POST['lastname'],
		'firstname' => $_POST['firstname'],
		'pseudo' => $_POST['PSEUDO'],
		'regEmailAddress' => $regEmailAddress,
		'regPassword' => md5($regPassword),
		'promotion' => $promotion,
		'year' => $year,
		'ecole' => $ecole,
		));
		echo 'Vous êtes inscrit';
		}
		else{
	//Affichage du formulaire :
	echo '
	<form method="post" action="formulaire_inscription.php">
	<fieldset>
	<legend>Informations personnelles</legend>
		<p>
			<label for="lastname">Nom :</label><input type="text" id="lastname" name="lastname"/>
		</p>
		<p>
			<label for="prenom">Prénom :</label><input type="text" id="firstname" name="firstname"/>
		</p>
		<p>
			<label for="pseudo">Pseudo :</label><input type="text" id="pseudo" name="pseudo"/>
		</p>
		<p>
			<label for="regEmailAddress">Adresse e-mail :</label>
            <input type="text" id="regEmailAddress" name="regEmailAddress" maxlength="200">
            <span id="regEmailAddressError" class="error" style="display:none"></span>
        </p>
		<p>
			<label for="regPassword">Mot de passe :</label>
			<input type="password" id="regPassword" name="regPassword" maxlength="200">
        </p>
        <p>
			<label for="regPassword2">Confirmation :</label>
			<input type="password" id="regPassword2" name="regPassword2" maxlength="200">
        </p>
			<select class="noreset" name="promotion">
			<option selected="" value="promotion">Sélectionne ta classe</option>
			<option value="BTS_SIO1">BTS SIO1</option>
			<option value="BTS_SIO2">BTS SIO2</option>
			<option value="Ingénieur 1">Ingénieur 1</option>
			<option value="Ingénieur 2">Ingénieur 2</option>
			<option value="Ingénieur 3">Ingénieur 3</option>
			<option value="Ingénieur 4">Ingénieur 4</option>
			</select>
		<p>
			<label for="année">Année :</label><input type="text" id="year" name="year"/>
		</p>
		<p>
			<label for="ecole">Ecole :</label><input type="text" id="ecole" name="ecole"/>
		</p>
	</fieldset>
	<div style="text-align:center;">
	<INPUT type="reset" value="Réinitialiser">
	<INPUT type="submit" value="Envoyer">
	</form>';
}
?>
</section>
</body>
</html>	